package com.bw.shop2208a.adapter

import android.graphics.Color
import android.graphics.Point
import android.graphics.drawable.ColorDrawable
import android.view.View
import android.widget.TextView
import com.bw.shop2208a.R
import com.bw.shop2208a.entity.DataGoodsTypeEntity
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class GoodsTypeOneAdapter : BaseQuickAdapter<DataGoodsTypeEntity,BaseViewHolder>(R.layout.item_goods_type_one) {
    private var selectedPosition = 0
    override fun convert(holder: BaseViewHolder, item: DataGoodsTypeEntity) {
        holder.setText(R.id.tv,item.category_name)
        if (holder.adapterPosition == selectedPosition){
            holder.itemView.setBackgroundColor(Color.BLACK)
            holder.getView<TextView>(R.id.tv).setTextColor(Color.WHITE)
        }else{
            holder.itemView.setBackgroundColor(Color.WHITE)
            holder.getView<TextView>(R.id.tv).setTextColor(Color.BLACK)
        }
    }
    fun setselectedPosition(position:Int){
        selectedPosition = position
        notifyDataSetChanged()
    }
}